<template>
  <div>
    <h3 class="dialog-plate-title mt-1"><span>今日检测</span></h3>
    <el-button type="primary" @click="showDialog()">新增</el-button> 
    <el-table :data="tableOuterCaseData" stripe border>
      <el-table-column prop="type" label="类型" sortable min-width="200"></el-table-column>
      <el-table-column prop="creatorName" label="发起医生" sortable min-width="200"></el-table-column>
      <el-table-column prop="createTime" label="发起日期" sortable min-width="200">
        <template slot-scope="scope">
          <div v-html="timestampToTime(scope.row.createTime,'yyyy-mm-dd hh:mm:ss')"></div>
        </template>
      </el-table-column>
    </el-table> 
    <h3 class="dialog-plate-title mt-1"><span>检测历史</span></h3>
    <el-table :data="tableOuterCaseHistoryData" stripe border>
      <el-table-column prop="type" label="类型" sortable min-width="200"></el-table-column>
      <el-table-column prop="creatorName" label="发起医生" sortable min-width="200"></el-table-column>
      <el-table-column prop="createTime" label="发起日期" sortable min-width="200">
        <template slot-scope="scope">
          <div v-html="timestampToTime(scope.row.createTime,'yyyy-mm-dd hh:mm:ss')"></div>
        </template>
      </el-table-column>
    </el-table>
    <!-- 新增详情 -->
    <el-dialog :visible.sync="dialog.open" title="新增院外检查" width="25%" top="70px" :close-on-click-modal="false" class="bodyNopaddingTop">
        <el-form :model="dialog.formData" label-width="100px">
          <el-form-item label="检测类型" prop="type"> 
            <el-select v-model="dialog.formData.type">
              <el-option key="血液检测" value="血液检测" label="血液检测" ></el-option>  
              <el-option key="CT检测" value="CT检测" label="CT检测"></el-option>
              <el-option key="超声检查" value="超声检查" label="超声检查"></el-option>
              <el-option key="其他" value="其他" label="其他"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item > 
             <el-button type="primary" @click="submit">提交</el-button>
          </el-form-item> 
        </el-form>
      </el-dialog>
  </div>
</template>
<script>
import {outHospitalExamineTodayList,outHospitalExamineHistoryList,insertOutHospitalExamineToday} from "plugins/axios/inquiryRecord.js"
export default {
  props:{
    pid:{
      type:[String,Number]
    },
    providerId:{
      type:[String,Number]
    }
  },
  data(){
    return {
      tableOuterCaseData:[],
      tableOuterCaseHistoryData:[],
      dialog:{
        open:false,
        formData:{}
      }
    }
  },
  created(){},
  mounted(){},
  watch:{},
  computed:{},
  methods:{
    init(){
      this.getOutHospitalExamineTodayList();
      this.getOutHospitalExamineHistoryList();
    },
    showDialog(){
      this.dialog.open=true;
      this.dialog.formData={};
    },
    // 获取院外检查-今日检查列表
    getOutHospitalExamineTodayList(){
      let self = this;
      outHospitalExamineTodayList(self.pid).then(res=>{
        self.tableOuterCaseData=res.content;
      })
    },
    getOutHospitalExamineHistoryList(){
      let self = this;
      outHospitalExamineHistoryList(self.providerId).then(res=>{
        self.tableOuterCaseHistoryData=res.content
      })
    },
    submit(){
      let self = this;
      let postData={
        hid:self.pid,
        ...self.dialog.formData
      }
      insertOutHospitalExamineToday(postData).then(res=>{
        self.$message.success("新增成功");
        self.dialog.open=false;
        self.init();
      })
    }
  }
}
</script>
<style scoped>
</style>